fix: forward cancelled tasks to the inner task #1236
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1210
Imagine Page.waitForSelector, if a user cancels one of these api calls, the internal protocol calls are still pending and don't get canceled. When one of these errors out it setts the exception and it ends up in
'Future exception was never retrieved'
(asyncio warning). I thought about two ways so far of fixing it:a) if the outer task gets canceled "propagate" the canceled signal down to the protocol api call, see here for an impl: 2f8041c
b) store the "outer task" inside the ProtocolCallback class and check when receiving the error if it was canceled: https://github.com/microsoft/playwright-python/pull/1236/files
Not sure whats better! b) is definitely less code.
The failing lint is unrelated, it gets fixed in #1237.